home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / examples.arc / EXAMPL50.PRO < prev    next >
Text File  |  1986-10-07  |  564b  |  27 lines

  1. /* program 50*/
  2. /*
  3.   This program uses random to select three
  4.   names from five at random.
  5. */  
  6.  
  7. predicates
  8.     person(integer,symbol)
  9.     rand_int_1_5(integer)
  10.     rand_person(integer)
  11.  
  12. goal
  13.     clearwindow,
  14.     rand_person(3).
  15.  
  16. clauses
  17.     person(1,fred).
  18.     person(2,tom).
  19.     person(3,mary).
  20.     person(4,dick).
  21.     person(5,george).
  22.     rand_int_1_5(X) :- random(Y),X=Y*4+1.
  23.     rand_person(0):-!.
  24.     rand_person(Count):-
  25.         rand_int_1_5(N),person(N,Name),nl,nl,write(Name),nl,
  26.         Newcount=Count-1,rand_person(NewCount).
  27.